Monte carlo method is a stochastic approximation based on sampling.
Application
An important application of this method is the intergral calculation.
For , where is a posterior distribution with latent variable and observed data , one can calculate the expectation of the posterior via sampling:
Then a question comes along: How to know the posterior? How to sample from the posterior?
Sampling Methods
There are several sampling methods.
Sampling via CDF
Ideally, if one samples and locates it on Y-axis of a CDF, a corresponding inverse CDF can be acquired.
This method only works for very simple PDF/CDF forms, e.g. normal distributions.
Rejection sampling
Rejection sampling means that for the probability of , if it falls in the area under , we accept it; if it falls outside the area of and inside the area of (where is a proposal distribution, and is always larger than ), we reject it, i.e. :
then we define as the ratio of acceptance, i.e.
Rejection sampling steps:
sample
sample
decision:
if , accept ;
else, reject
Importance sampling
Importance sampling samples from the expectations .
where the is the weight, and again is a proposal distribution.